package com.battery.controller;


import com.battery.pojo.dict;
import com.battery.service.DictService;
import com.battery.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Api(tags = "字典管理相关接口")
public class DictController {
    @Autowired
    DictService dict;

    @PostMapping("/getAllDict")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("获取所有字典")
    public Result getAllDict(){

        return dict.getDict();

    }

    @PutMapping("/updateDict")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("更新某一字典信息")
    public Result updateFeedback(@RequestBody @ApiParam(name = "传入json") dict dic){
        return dict.updateDict(dic);
    }

    @DeleteMapping("/deleteDict")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("删除某一字典")
    public Result deleteFeedback(@ApiParam(name = "传入id") int id){
        return dict.deleteDict(id);
    }

}
